#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>

void printids(const char *s)
{
	pid_t pid;
	pthread_t tid;

	pid = getpid();
	tid = pthread_self();

	printf("%s: pid %u tid %u (0x%x)\n",s,(unsigned int)pid,(unsigned int)tid,(unsigned int)tid);
	return;
}

void *test_pthread(void *arg)
{
	//printids("new pthread:");
	printids(__FUNCTION__);
	while(1)
	{
		sleep(5);
	}

	return (void *)0;
}

int main(int argc, char *argv[])
{
	int ret = 0;
	pthread_t tid;
	void *arg = (void *)10;

	signal(SIGINT, SIG_DFL);

	ret = pthread_create(&tid, NULL, test_pthread, arg);

	printids("main pthread");
	while(1)
	{
		sleep(3);
	}
	pthread_join(tid,NULL);

	return 0;
}

